package com.hdculture.apis.grapi;

import android.view.*;
import android.widget.Toast;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.Paint.Align;
import android.graphics.Paint.Style;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.HashMap;

/*
 * @author	Manthan
 */
public abstract class GrAPI extends View {
	/*
	 * Protected methods...
	 */
	public static final String LINE = "LINE";
	public static final String BAR = "BAR";

	/*
	 * Private methods...
	 */
	private Context context;
	private String[] xLabels;
	private String[] yLabels;
	private double[] values1;
	private double[] values2; // Needs to be setted and getted
	private ArrayList<Graph> displayableGraphs = new ArrayList<Graph>();

	private String caption;
	private String type;
	private int x, y;

	private double scale;
	private Rect xPanel, yPanel, captionPanel, graphPanel; // Panels

	// Default colors...
	private int xyPanelColor = Color.DKGRAY, xyAxisColor = Color.WHITE,
			xyTextColor = Color.WHITE, xyCaptionColor = Color.WHITE,
			graphCaptionColor = Color.DKGRAY,
			graphCaptionTextColor = Color.WHITE,
			graphButtonColor = Color.WHITE, graphButtonTextColor = Color.BLACK,
			graphPanelColor = Color.WHITE, graphPointColor = Color.BLACK,
			values1Color = Color.BLACK, values2Color = Color.DKGRAY;

	private double yPanelAlloc = 0.15, xPanelAlloc = 0.15,
			captionPanelAlloc = 0.10; // 20% allocation for both panels
	private Paint panelPaint, textPaint, linePaint, graphPanelPaint,
			graphPointPaint, graph1Paint, graph2Paint;
	private Rect leftButton, rightButton; // Graph Navigation Buttons
	private int graphStart, interval;
	private int initGraphStart, initInterval;
	double lastX1 = 0, lastX2 = 0;
	private double[] xValue1, yValue1, xValue2, yValue2;
	private String xCaption, yCaption;
	private int maxY;

	/*
	 * Abstract methods...
	 */
	abstract void onPointTouch(int pointIndex, int graphIndex);

	public GrAPI(Context context, String[] xLabels, String xCaption,
			String yCaption, double[] values1, String graphCaption,
			String type, boolean shading) {
		super(context);
		this.context = context;
		this.xLabels = xLabels;
		this.values1 = values1;
		this.caption = graphCaption;
		this.type = type;
		this.xCaption = xCaption;
		this.yCaption = yCaption;
		displayableGraphs.add(new Graph(displayableGraphs.size(), values1,
				Color.BLACK, type, shading));
		scale = context.getResources().getDisplayMetrics().density;
		preparePaints(); // This method initializes all paints;
		handleTouch();
		initInterval = (int) (50 * scale);
		interval = initInterval;
		initGraphStart = (int) ((getWidth() - (getWidth() * yPanelAlloc)));
		graphStart = initGraphStart;
		double max = getMax(displayableGraphs);
		maxY = (int) (max + (max * 0.25));

	}

	@Override
	protected void onDraw(final Canvas canvas) {
		// TODO Auto-generated method stub
		canvas.drawColor(Color.WHITE);
		// Paint linePaint = new Paint();
		// linePaint.setAntiAlias(true);
		// linePaint.setColor(Color.BLACK);
		// linePaint.setStyle(Style.STROKE);
		// canvas.drawLine(x, y, x+100, y+100, linePaint);
		/*
		 * Methods to create YAxis panel and XAxis panel is here at the end It
		 * should remain at the end.
		 */
		generateGraphPanel(canvas);
		createGraph(canvas);
		createXPanel(canvas);
		createYPanel(canvas);
		createCaptionPanel(canvas);
		generateXAxis(canvas);
		generateYAxis(canvas);
		initializeNavigation(canvas);

		super.onDraw(canvas);
	}

	private void refreshScreen() {
		super.invalidate();
	}

	private void createXPanel(Canvas c) {
		int left = 0;

		int right = getWidth();
		// int top=(int) (getHeight()-getHeight()*xPanelAlloc);
		int top = graphPanel.bottom;
		int bottom = getHeight();
		xPanel = new Rect();
		xPanel.set(left, top, right, bottom);
		panelPaint.setColor(xyPanelColor);
		c.drawRect(xPanel, panelPaint);
		// Setting up labels...
		textPaint.setTextAlign(Align.CENTER);
		textPaint.setTextSize((float) (12 * scale));
		textPaint.setColor(xyAxisColor);
		for (int i = 0; i < Array.getLength(xLabels); i++) {
			int x = graphStart + (interval * (i + 2));
			int y = (int) (xPanel.top - 2);
			c.drawLine(x, y, x, y + 4, textPaint);
			y++;
			c.drawText(xLabels[i], x,
					(int) (y + textPaint.getTextSize() + (5 * scale)),
					textPaint);
		}
		int x = xPanel.centerX() + (graphPanel.left / 2);
		int y = xPanel.centerY() + (xPanel.centerY() / 22);
		textPaint.setTextAlign(Align.CENTER);
		textPaint.setColor(xyCaptionColor);
		c.drawText(xCaption, x, y, textPaint);
	}

	private void createYPanel(Canvas c) {
		int left = 0;
		// int right=(int) (getWidth()*yPanelAlloc); //20% of the width is
		// occupied
		int right = graphPanel.left;
		int top = 0;
		int bottom = getHeight();
		yPanel = new Rect();
		yPanel.set(left, top, right, bottom);
		panelPaint.setColor(xyPanelColor);
		c.drawRect(yPanel, panelPaint);
		// Setting up labels...
		int now = maxY;
		int segment = maxY / 8;
		int[] labels = new int[8];
		for (int i = 0; i < 8; i++) {
			if ((now - segment) > 0) {
				now -= segment;
				labels[i] = now;
			}
		}
		int axisHeight = (int) (xPanel.top - (getHeight() - (getHeight() * (1 - captionPanelAlloc))));
		int axisStart = (int) (getHeight() - (getHeight() * (1 - captionPanelAlloc)));
		int axisSegment = axisHeight / 8;

		textPaint.setTextAlign(Align.RIGHT);
		textPaint.setTextSize((float) (12 * scale));
		textPaint.setColor(xyAxisColor);
		int y = (int) (axisStart + (textPaint.getTextSize() / 2));
		for (int i = 0; i < Array.getLength(labels) - 1; i++) {
			int x = yPanel.right;
			y += axisSegment;
			c.drawLine(x, y, x - 4, y, textPaint);
			x -= 8;
			c.drawText(labels[i] + "", x, y + (textPaint.getTextSize() / 2),
					textPaint);

		}
		// Drawing the axis label...
		int x = yPanel.centerX() / 2;
		y = yPanel.centerY();
		textPaint.setTextAlign(Align.CENTER);
		textPaint.setColor(xyCaptionColor);
		c.save();
		c.rotate(-90, x, y);
		c.drawText(yCaption, x, y, textPaint);
		c.restore();
	}

	private void generateXAxis(Canvas c) {
		if (xPanel != null) {
			int xOffset = (int) (10 * scale);
			int xStart, yStart, xEnd, yEnd;
			xStart = yPanel.right - xOffset;
			xEnd = getWidth();
			yStart = xPanel.top;
			yEnd = yStart; // Because y will remain constant
			linePaint.setColor(xyAxisColor);
			c.drawLine(xStart, yStart, xEnd, yEnd, linePaint);
		}
	}

	private void generateYAxis(Canvas c) {
		if (yPanel != null) {
			int yOffset = (int) (10 * scale);
			int xStart, yStart, xEnd, yEnd;
			xStart = yPanel.right;
			xEnd = xStart;
			yStart = captionPanel.bottom;
			yEnd = xPanel.top + yOffset; // Because y will remain constant
			linePaint.setColor(xyAxisColor);
			c.drawLine(xStart, yStart, xEnd, yEnd, linePaint);
		}
	}

	private void createCaptionPanel(Canvas c) {
		int left = 0;
		int right = getWidth();
		int top = 0;
		int bottom = (int) (getHeight() - (getHeight() * (1 - captionPanelAlloc))); // Using
																					// 10%
																					// of
																					// height
		captionPanel = new Rect();
		captionPanel.set(left, top, right, bottom);
		panelPaint.setColor(graphCaptionColor);
		c.drawRect(captionPanel, panelPaint);
		if (caption != null) {
			textPaint.setTextAlign(Align.CENTER);
			textPaint.setColor(graphCaptionTextColor);
			c.drawText(caption, captionPanel.centerX() + yPanel.centerX(),
					captionPanel.centerY() + (textPaint.getTextSize() / 2),
					textPaint);
			preparePaints();
		}
	}

	private void generateGraphPanel(Canvas c) {
		graphPanel = new Rect();
		int left, top, right, bottom;
		left = (int) (getWidth() * yPanelAlloc);
		right = (int) (getWidth());
		top = (int) (getHeight() - (getHeight() * (1 - captionPanelAlloc)));
		bottom = (int) (getHeight() - (getHeight() * xPanelAlloc));
		// graphPanel.set(yPanel.right, captionPanel.bottom, getWidth(),
		// xPanel.top);
		graphPanel.set(left, top, right, bottom);
		graphPanelPaint.setColor(graphPanelColor);
		c.drawRect(graphPanel, graphPanelPaint);
	}

	private void preparePaints() {
		// Preparing panelPaint...
		panelPaint = new Paint();
		panelPaint.setColor(Color.DKGRAY);
		panelPaint.setStyle(Style.FILL_AND_STROKE);
		panelPaint.setAntiAlias(true);
		panelPaint.setStrokeWidth(5);

		// Preparing textPaint...
		textPaint = new Paint();
		textPaint.setColor(Color.WHITE);
		textPaint.setTextSize((float) (18 * scale));
		textPaint.setStyle(Style.FILL_AND_STROKE);
		textPaint.setFakeBoldText(true);
		textPaint.setAntiAlias(true);

		// Preparing linePaint...
		linePaint = new Paint();
		linePaint.setColor(Color.WHITE);
		linePaint.setStyle(Style.STROKE);
		linePaint.setAntiAlias(true);

		// Preparing graphPanelPaint...
		graphPanelPaint = new Paint();
		graphPanelPaint.setColor(Color.WHITE);
		graphPanelPaint.setStyle(Style.FILL);
		graphPanelPaint.setAntiAlias(true);

		// Preparing graphPointPaint...
		graphPointPaint = new Paint();
		graphPointPaint.setColor(Color.BLACK);
		graphPointPaint.setAntiAlias(true);
		graphPointPaint.setStyle(Style.FILL);
		// graphPointPaint.setShadowLayer(1, -2, 2, Color.DKGRAY);

		// Preparing graph1Paint...
		graph1Paint = new Paint();
		graph1Paint.setColor(Color.BLACK);
		graph1Paint.setAlpha(80);
		graph1Paint.setAntiAlias(true);
		graph1Paint.setStyle(Style.FILL_AND_STROKE);
		// graph1Paint.setShadowLayer(1, -2, 2, Color.DKGRAY);

		// Preparing graph2Paint...
		graph2Paint = new Paint();
		graph2Paint.setColor(Color.LTGRAY);
		graph2Paint.setAlpha(80);
		graph2Paint.setAntiAlias(true);
		graph2Paint.setStyle(Style.FILL_AND_STROKE);
		// graph2Paint.setShadowLayer(1, -2, 2, Color.DKGRAY);
	}

	// Methods of interaction here...
	private void initializeNavigation(Canvas c) {
		int buttonSize = (int) (75 * scale);
		leftButton = new Rect();
		leftButton.set(yPanel.right, 0, yPanel.right + buttonSize,
				captionPanel.bottom);
		rightButton = new Rect();
		rightButton.set(getWidth() - buttonSize, 0, getWidth(),
				captionPanel.bottom);
		linePaint.setColor(graphButtonColor);
		linePaint.setStyle(Style.FILL_AND_STROKE);
		c.drawRect(leftButton, linePaint);
		c.drawRect(rightButton, linePaint);
		preparePaints();
		// Time to draw text on buttons
		textPaint.setTextAlign(Align.CENTER);
		textPaint.setColor(graphButtonTextColor);
		int x = leftButton.centerX();
		int y = (int) (leftButton.centerY() + (textPaint.getTextSize() / 2));
		c.drawText("-", x, y, textPaint);
		x = rightButton.centerX();
		y = (int) (rightButton.centerY() + (textPaint.getTextSize() / 2));
		c.drawText("+", x, y, textPaint);
	}

	private void createGraph(Canvas c) {

		for (int i = displayableGraphs.size() - 1; i >= 0; i--) {
			double max = getMax(displayableGraphs);
			maxY = (int) (max + (max * 0.25));
			Graph g = displayableGraphs.get(i);

			double baseValue = getHeight() - (getHeight() * xPanelAlloc); // This
																			// is
																			// the
																			// start
																			// of
																			// x
																			// axis
																			// considered
																			// as
																			// 0
			double[] values, xValue, yValue;
			values = g.getValue();
			xValue = new double[Array.getLength(values)];
			yValue = new double[Array.getLength(values)];
			Path line2Path = new Path();
			if (g.getShading() == true) {
				line2Path.moveTo(graphStart + (interval * (2)),
						(float) baseValue);
			}
			graphPointPaint.setColor(graphPointColor);
			// graphPointPaint.setAlpha(80);
			graph2Paint.setColor(g.getGraphColor());
			graph2Paint.setAlpha(80);
			graph2Paint.setStyle(Style.FILL);
			for (int j = 0; j < Array.getLength(values); j++) {
				xValue[j] = graphStart + (interval * (j + 2));
				double graphHeight = baseValue
						- (getHeight() - (getHeight() * (1 - captionPanelAlloc)));
				yValue[j] = baseValue - ((values[j] / maxY) * graphHeight);
				if (g.getType().contains(LINE)) {
					if (g.getShading() == true || j != 0)
						line2Path.lineTo((float) xValue[j], (float) yValue[j]);
					else if (g.getShading() == false && j == 0)
						line2Path.moveTo((float) xValue[j], (float) yValue[j]);

					c.drawCircle((float) xValue[j], (float) yValue[j],
							(float) (5 * scale), graphPointPaint);

				}
				if (g.getType().contains(BAR)) {
					Rect bar = new Rect();
					bar.set((int) (xValue[j] - g.getBarWidth()),
							(int) (yValue[j]),
							(int) (xValue[j] + g.getBarWidth()),
							(int) graphPanel.bottom);
					c.drawRect(bar, graph2Paint);
				}
				try {
					if (lastX2 < xValue[j]) {
						lastX2 = xValue[j];
					}
				} catch (Exception ex) {
					lastX2 = xValue[j];
				}
				lastX1 = xValue[j];
				displayableGraphs.get(i).setxPoint(xValue);
				displayableGraphs.get(i).setyPoint(yValue);
			}
			if (g.getShading() == true) {
				line2Path.lineTo((float) lastX1, (float) baseValue);
				line2Path.lineTo(graphStart + (interval * (2)),
						(float) baseValue);
				graph2Paint.setColor(g.getGraphColor());
				graph2Paint.setAlpha(80);
				graph2Paint.setStyle(Style.FILL);
				c.drawPath(line2Path, graph2Paint);
			}
			// c.drawPath(line2Path, graph2Paint);
			graph2Paint.setStyle(Style.STROKE);
			if (g.getShading() == true) {
				graph2Paint.setColor(Color.BLACK);
			} else {
				graph2Paint.setColor(g.getGraphColor());
			}
			graph2Paint.setStrokeWidth((float) (1 * scale));
			c.drawPath(line2Path, graph2Paint);

		}
	}

	boolean fingerMoved = false;

	private void handleTouch() {
		this.setOnTouchListener(new OnTouchListener() {

			@Override
			public boolean onTouch(View v, MotionEvent event) {

				System.out.println(event.getHistorySize());
				float x = event.getX();
				float y = event.getY();
				float xh, yh;
				if (event.getHistorySize() > 0) {
					xh = event.getHistoricalX(0);
					yh = event.getHistoricalY(0);
				}else{
					xh=x;
					yh=y;
				}
				float dist = (float) makePositive(xh - x);
				if (graphPanel.contains((int) x, (int) y)) {
					int action = event.getAction();
					if (action == MotionEvent.ACTION_DOWN) {
						fingerMoved = false;

					} else if (action == MotionEvent.ACTION_UP) {
						// Indicates that a tap has occurred...
						final int dr = 15;
						boolean detected = false;
						for (int i = 0; i < displayableGraphs.size(); i++) {
							Graph g = displayableGraphs.get(i);
							for (int j = 0; j < Array.getLength(g.getValue()); j++) {
								double[] xValue = g.getxPoint(), yValue = g
										.getyPoint();
								Rect r = new Rect();
								r.set((int) (xValue[j] - (dr * scale)),
										(int) (yValue[j] - (dr * scale)),
										(int) (xValue[j] + (dr * scale)),
										(int) (yValue[j] + (dr * scale)));
								if (r.contains((int) x, (int) y)) {
									onPointTouch(j, i); // To be defined by
														// user
									// second arg is point graph index which
									// is
									// the index value of graph.
									// 0 for foreground and 1 for background
									i = displayableGraphs.size() - 1; // Ending
																		// the
																		// loop
									detected = true;
								}
							}
						}
						// if(detected==false){
						// for(int i=0;i<Array.getLength(xValue2);i++){
						// Rect r = new Rect();
						// r.set((int) (xValue2[i]-(dr*scale)),(int)
						// (yValue2[i]-(dr*scale)),(int)
						// (xValue2[i]+(dr*scale)), (int)
						// (yValue2[i]+(dr*scale)));
						// if(r.contains((int) x, (int) y)){
						// onPointTouch(i, 1); //To be defined by user
						// //second arg is point graph index which is the
						// index
						// value of graph.
						// //0 for foreground and 1 for background
						// i=Array.getLength(xValue2)-1; //Ending the loop
						// detected=true;
						// }
						// }
						// }
					}
				} else if (xPanel.contains((int) x, (int) y)) {
					int action = event.getAction();
					if (action == MotionEvent.ACTION_MOVE) {
						fingerMoved = true;
						v.setPressed(false);
						if (event.getPointerCount() == 2
								&& event.getHistorySize() >= 1) {
							// Two fingers are there
							double x1, x2, hx1, hx2;
							x1 = event.getX(0);
							x2 = event.getX(1);
							hx1 = event.getHistoricalX(0, 0);
							hx2 = event.getHistoricalX(1, 0);
							System.out.println("X1: " + x1 + " X2:" + x2);
							System.out.println("HX1: " + hx1 + " HX2:" + hx2);
							double hdistance = makePositive(hx1 - hx2);
							double distance = makePositive(x1 - x2);
							if (hdistance > distance) { // Its a pinch!
								if ((interval - 5) > 0)
									interval -= 5;
							} else {
								if ((interval + 5) < getWidth())
									interval += 5;
							}

						} else if (event.getPointerCount() == 1) {
							if (event.getHistorySize() > 0) {
								float oldX = event.getHistoricalX(0);
								if (x > oldX) {
									float increment = (x - oldX) * 3;
									if ((graphStart + increment) <= (yPanel.right)) {
										graphStart += increment;
										System.out.println(x - oldX);
									}
								} else {
									double end = lastX2;
									// if(lastX1>lastX2){
									// end=lastX1;
									// }else{
									// end=lastX2;
									// }
									// initGraphStart*3
									if (end >= (getWidth() - yPanel.centerX())) {
										float decrement = (oldX - x) * 3;
										graphStart -= decrement;
										System.out.println(oldX - x);
									}
								}
							}
						}
					}
				} else if (leftButton.contains((int) x, (int) y)) {
					if ((interval - 10) > 0)
						interval -= 10;
				} else if (rightButton.contains((int) x, (int) y)) {
					if ((interval + 10) < getWidth())
						interval += 10;
				}

				refreshScreen();

				return true;

			}

		});

		// this.setOnClickListener(new OnClickListener() {
		//
		// @Override
		// public void onClick(View v) {
		// // TODO Auto-generated method stub
		// final int dr=15;
		// boolean detected=false;
		// for(int i=0;i<displayableGraphs.size();i++){
		// Graph g = displayableGraphs.get(i);
		// for(int j=0;j<Array.getLength(g.getValue());j++){
		// double[] xValue = g.getxPoint(), yValue = g.getyPoint();
		// Rect r = new Rect();
		// r.set((int) (xValue[j]-(dr*scale)),(int) (yValue[j]-(dr*scale)),(int)
		// (xValue[j]+(dr*scale)), (int) (yValue[j]+(dr*scale)));
		// if(r.contains((int) x, (int) y)){
		// onPointTouch(j, i); //To be defined by user
		// //second arg is point graph index which is the index value of graph.
		// //0 for foreground and 1 for background
		// i=displayableGraphs.size()-1; //Ending the loop
		// detected=true;
		// }
		// }
		// }
		//
		// }
		// });
	}

	private double makePositive(double value) {
		if (value < 0) {
			value = 0 - value;
		}
		return value;
	}

	private double getMax(ArrayList<Graph> displayableGraphs) {
		double maxValue = 0;
		for (int i = 0; i < displayableGraphs.size(); i++) {
			Graph g = displayableGraphs.get(i);
			double[] values = g.getValue();
			for (int j = 0; j < Array.getLength(values); j++) {
				if (maxValue < values[j])
					maxValue = values[j];
			}
		}
		return maxValue;
	}

	/*
	 * Gets the array of values to be displayed in background
	 */
	public double[] getValues2() {
		return values2;
	}

	/*
	 * Sets the array of values to be displayed in background
	 */
	public void setValues2(double[] values2) {
		this.values2 = values2;
	}

	/*
	 * Gets the color of the X Panel and Y Panel as integer value
	 */
	public int getXyPanelColor() {
		return xyPanelColor;
	}

	/*
	 * Sets the color of the X Panel and Y Panel as integer. This is usually
	 * Color.DKGRAY
	 */
	public void setXyPanelColor(int xyPanelColor) {
		this.xyPanelColor = xyPanelColor;
	}

	/*
	 * Gets the color of the X and Y Axis as integer
	 */
	public int getXyAxisColor() {
		return xyAxisColor;
	}

	/*
	 * Sets the color of the X and Y Axis as integer. This is usually
	 * Color.WHITE
	 */
	public void setXyAxisColor(int xyAxisColor) {
		this.xyAxisColor = xyAxisColor;
	}

	/*
	 * Gets the color of the text on X and Y Axis
	 */
	public int getXyTextColor() {
		return xyTextColor;
	}

	/*
	 * Sets the color of the text on X and Y Axis. This is usually Color.WHITE
	 */
	public void setXyTextColor(int xyTextColor) {
		this.xyTextColor = xyTextColor;
	}

	/*
	 * Gets the color of caption on X and Y Axis as int
	 */
	public int getXyCaptionColor() {
		return xyCaptionColor;
	}

	/*
	 * Sets the color of caption on X and Y Axis as int. This is usually
	 * Color.WHITE
	 */
	public void setXyCaptionColor(int xyCaptionColor) {
		this.xyCaptionColor = xyCaptionColor;
	}

	/*
	 * Gets the color of the title of graph
	 */
	public int getGraphCaptionColor() {
		return graphCaptionColor;
	}

	/*
	 * Sets the color of the title of graph. This is usually Color.WHITE
	 */
	public void setGraphCaptionColor(int graphCaptionColor) {
		this.graphCaptionColor = graphCaptionColor;
	}

	/*
	 * Gets the color of the buttons above graph which are used to expand or
	 * contract the graph
	 */
	public int getGraphButtonColor() {
		return graphButtonColor;
	}

	/*
	 * Sets the color of the buttons above the graph which are used to expand or
	 * contract the graph.
	 */
	public void setGraphButtonColor(int graphButtonColor) {
		this.graphButtonColor = graphButtonColor;
	}

	/*
	 * Gets the color of the text on the buttons above the graph
	 */
	public int getGraphButtonTextColor() {
		return graphButtonTextColor;
	}

	/*
	 * Sets the color of the text on the buttons above the graph. This is
	 * usually Color.WHITE
	 */
	public void setGraphButtonTextColor(int graphButtonTextColor) {
		this.graphButtonTextColor = graphButtonTextColor;
	}

	/*
	 * Gets the color of the graph panel
	 */
	public int getGraphPanelColor() {
		return graphPanelColor;
	}

	/*
	 * Sets the color of the graph panel. This is usually Color.WHITE
	 */
	public void setGraphPanelColor(int graphPanelColor) {
		this.graphPanelColor = graphPanelColor;
	}

	/*
	 * Gets the color of the points in the graph
	 */
	public int getGraphPointColor() {
		return graphPointColor;
	}

	/*
	 * Sets the color of the points in the graph. This is usually Color.BLACK
	 */
	public void setGraphPointColor(int graphPointColor) {
		this.graphPointColor = graphPointColor;
	}

	/*
	 * Gets the color of the area of foreground values. This is usually darker
	 * than the background values
	 */
	public int getValues1Color() {
		return values1Color;
	}

	/*
	 * Sets the color of the area of foreground values. This is usually darker
	 * than the background values
	 */
	public void setValues1Color(int values1Color) {
		this.values1Color = values1Color;
	}

	/*
	 * Gets the color of the area of background values. This is usually lighter
	 * than the background values
	 */
	public int getValues2Color() {
		return values2Color;
	}

	/*
	 * Sets the color of the area of background values. This is usually lighter
	 * than the background values
	 */
	public void setValues2Color(int values2Color) {
		this.values2Color = values2Color;
	}

	public ArrayList<Graph> getDisplayableGraphs() {
		return displayableGraphs;
	}

	public void addDisplayableGraph(double[] values, int graphColor,
			String type, boolean shading) {
		displayableGraphs.add(new Graph(displayableGraphs.size(), values,
				graphColor, type, shading));
		refreshScreen();
	}
}
